package miku.firstgame.model
{
	import flash.media.Video;

	import miku.firstgame.net.ByteArrayEx;

	public class Room
	{
		private var _roomId:int;
		private var _roomName:String;
		private var _roomMaster:User;

		private var _userCount:int = 0;

		private var _maxUserCount:int = 8;

		public function Room()
		{
		}

		public function get roomMaster():User
		{
			return _roomMaster;
		}

		public function set roomMaster(value:User):void
		{
			_roomMaster = value;
		}

		public function get maxUserCount():int
		{
			return _maxUserCount;
		}

		public function set maxUserCount(value:int):void
		{
			_maxUserCount = value;
		}

		public function get userCount():int
		{
			return _userCount;
		}

		public function set userCount(value:int):void
		{
			_userCount = value;
		}

		public function get roomName():String
		{
			return _roomName;
		}

		public function set roomName(value:String):void
		{
			_roomName = value;
		}

		public function get roomId():int
		{
			return _roomId;
		}

		public function set roomId(value:int):void
		{
			_roomId = value;
		}

		public static function parseRoom(data:ByteArrayEx):Room
		{
			var id:int = data.readUnsignedInt();
			var userCount:int = data.readUnsignedInt();
			var maxCount:int = data.readUnsignedInt();
			var name:String = data.readString();

			var room:Room = new Room();
			room.roomId = id;
			room.userCount = userCount;
			room.maxUserCount = maxCount;
			room.roomName = name;
			return room;

		}

	}
}
